import { ServiceConfig, Guid } from '../../src/common';
import { FBSDataContextBase, DataContextFactory } from '../../src/domain/fbsDataContext';
import { FrontStoreStockService } from "../../src/service/frontStoreStockService";
import { Inventory, Kitchensolution } from "../../src/domain/model";

import * as assert from 'assert';
import lodash = require('lodash');

const webconfig = require("../../../webconfig").webconfig;
let moment = require('moment');

describe('/service/frontStoreStockService', async function () {
    let ctx: FBSDataContextBase = DataContextFactory.GetDataContext();
    let frontStoreStockSvr: FrontStoreStockService = ServiceConfig.Current.GetService<FrontStoreStockService>('frontStoreStockService');;

    let store = {
        owner: {
            mobile: '18583920602',
            name: '单元测试用人',
            id: 'testUserId'
        },
        branchName: '单元测试用店',
        id: ''
    };
    let inventories = [
        { id: 'testInventory1', name: '小吃拼盘' },
        { id: 'testInventory2', name: '牛肉拼盘' },
        { id: 'testInventory3', name: '素菜拼盘' }
    ];
    let categories = [
        { name: 'xx', showOrder: 0, store: store }
    ];

    let trans = ctx.BeginTranscation();
    // 创建一个厨房解决方案
    let kitchensolution: Kitchensolution = new Kitchensolution();
    kitchensolution = Object.assign(kitchensolution, {
        id: 'testKitchensolutionId',
        name: '单元测试用厨显方案',
        categories: categories,
        inventories: inventories,
        media: 'kp',
        mode: 'default',
        store: store
    });
    await ctx.Create(kitchensolution);
    // 创建测试用的 inventory
    for (let o of inventories) {
        let inventory: Inventory = new Inventory();
        inventory.store = store;
        inventory.price = 100;
        inventory = Object.assign(inventory, o);
        await ctx.Create(inventory);
    }

    
    // 创建测试用的 inventory 关联的 frontStoreStocks
    // 创建测试用的 inventory 关联的 InventoryProduceInfo

    // 验证方法
    // CleanData 重置 frontStoreStocks 状态
    // GetStocksByInventoryIds 使用店铺编号和商品编号获取门店前端库存
    // GetFrontStoreStockList 获取门店前端库存（要通过厨房显示方案）
    // AugmentFrontStoreStock 制作商品（增加门店前端库存）
    // setFrontStoreStockSoldOut 卖完沽清（制作台）
    // setFrontStoreStockManual 手动沽清（POS端）
    // getSoldOutByInventoryId 获取某商品沽清状态（POS端使用）
    // cancelFrontStoreStockSoldOut 取消沽清
    // cancelAllFrontStoreStockSoldOut 全部取消沽清
    // GetStoreSoldOutInventoryIds 获取已沽清的商品 ID
    // SetScrapOut 门店前端商品库存报废
    // GetScrapOutList 获取报废历史记录 多次报废检查编号
})